package br.com.firula.dao;

import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

public class DaoSupport {
	class HibernateDao extends HibernateDaoSupport{
		public Session session(){
			return this.getSession();
		}
		public Session session(boolean b){
			return this.getSession(b);
		}
		public  DataAccessException convert(HibernateException ex){
			return convertHibernateAccessException(ex);
		}
	}

	HibernateDao support = new HibernateDao();
	@Autowired
	public void setSessionFactory(SessionFactory sessionFactory){
		support.setSessionFactory(sessionFactory);
	}

	protected Session getSession() {
		return support.session();
	}

	protected Session getSession(boolean b) {
		return support.session(b);
	}

	protected HibernateTemplate getHibernateTemplate() {
		return support.getHibernateTemplate();
	}

	protected DataAccessException convertHibernateAccessException(HibernateException ex) {
		return support.convert(ex);
	}
}